<template>
	<view class="contain">
		<view class="fixed">
			<cu-custom :isBack="false" :color="color" bgColor="bg-shadeTop" @goBack="goBack">
				<block slot="content">
					<!--<view class="content">选择分组</view>-->
					<view class="content">{{lang.team.selectgroup}}</view>
				</block>
			</cu-custom>
		</view>
		<view class="list">
			<view class="list-item" v-for="(v,k) in list" :key="k" @tap="changeTab(k,v.name)">{{v.name}}</view>
		</view>
	</view>
</template>

<script>
	import {mapState, mapMutations} from "vuex";
	export default {
		data() {
			return {
				color: '#333',
				list: []
			}
		},
		computed: {
			...mapState(["lang"])
		},
		onLoad() {
			this.init()
		},
		methods: {
			init() {
				let data1 = {
					ids: this.$store.state.paramList
				}
				this.$u.get('authc/api/user/find_by_excel_id', data1).then(res => {
					this.list = []
					for (let item in res.data) {
						this.list.push({
							name: item,
							content: res.data[item]
						})
					}
				})
			},
			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			/**
			 * 获取页面栈
			 * @param {Number} preIndex为1时获取上一页
			 * @return {Object} 
			 */
			 prePage(preIndex = 1){
				const pages = getCurrentPages();
				const prePage = pages[pages.length - (preIndex + 1)];
			
				return prePage.$vm;
			},
			changeTab(k,name) {
				this.prePage().changeNav(k,name);
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.contain {
		width: 100%;
		background: #F1F1F1;
		display: flex;
		flex-direction: column;
		align-items: center;
		
		.fixed {
			width: 100%;
		
			.content {
				width: 100%;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
		}
		
		.list {
			width: 100%;
			padding: 0 28rpx;
			box-sizing: border-box;
			background: #F1F1F1;
			margin-top: 30rpx;
		
			.list-item {
				width: 100%;
				padding: 30rpx 24rpx;
				box-sizing: border-box;
				background: #FFFFFF;
				border-radius: 6px;
				font-size: 28rpx;
				color: #333;
				margin-bottom: 30rpx;
			}
		}
	}
</style>
